import io
import os
import dealHtml
import dealTxt

def create_bat():
    f = open("temp/" + dealTxt.filename_edited_txt(dealHtml.url),'r')
    fr = open("temp/ts/" + dealTxt.filename_edited_txt(dealHtml.url) + '.bat', 'a')
    instruction = ['@echo\n','copy /b ']
    fr.writelines(instruction)
    for line in f.readlines():
        line = line.strip()
        line = line + '+'
        fr.write(line)
    fr = open("temp/ts/" + dealTxt.filename_edited_txt(dealHtml.url) + '.bat',"rb+")
    fr.seek(-1 ,os.SEEK_END)
    fr.truncate()
    fr.close()
    fr = open("temp/ts/" + dealTxt.filename_edited_txt(dealHtml.url) + '.bat', 'a')
    end = ' new.ts'
    fr.write(end)
    fr.close()
    f.close()